package com.aiyige.page.interest.selectpublishinterest.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.interest.model.Interest;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

public class SelectedInterestAdapter extends BaseQuickAdapter<Interest, SelectedInterestAdapter.ViewHolder> {

    public SelectedInterestAdapter() {
        super(R.layout.select_publish_interest_page_selected_interest_item, new LinkedList<Interest>());
    }

    @Override
    protected void convert(ViewHolder helper, Interest item) {
        helper.bindData(item);
    }


    public class ViewHolder extends BaseViewHolder {
        @BindView(R.id.titleTv)
        TextView titleTv;
        @BindView(R.id.selectIv)
        ImageView selectIv;
        @BindView(R.id.addIv)
        ImageView addIv;
        Interest data;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(Interest data) {
            this.data = data;
            switch (data.getType()) {
                case Interest.TYPE_ADD:
                    titleTv.setText("");
                    selectIv.setVisibility(View.INVISIBLE);
                    addIv.setVisibility(View.VISIBLE);
                    break;
                case Interest.TYPE_NORMAL:
                    titleTv.setText(data.getTitle());
                    selectIv.setVisibility(View.VISIBLE);
                    addIv.setVisibility(View.INVISIBLE);
                    break;
            }
        }
    }
}
